getParameters = function() {
	var ret = {};
	var queryString = window.location.search.substring(1);
	var params = queryString.split('&');
	for (var c=0; c<params.length; c++) {
    document.write(params[c]);
		var keyValue = params[c].split('=');
		ret[keyValue[0]] = unescape(keyValue[1]);
	}
	return ret;
};

onClientReady = function() {
	gapi.hangout.onApiReady.add(function(e){
		if(e.isApiReady) {
			onApiReady();
		}
	});
};

onApiReady = function() {
	var param = getParameters();
	var now = new Date();
	
	var hangoutUrl = gapi.hangout.getHangoutUrl();
	var callbackUrl = "register_hangout.json";
	
	$.ajax({
		url: callbackUrl,
		datatype: "json",
		data: {
			"hangoutUrl": hangoutUrl,
			"topic": param["input"]
		}
	}).done( function( date, statur, xhr ) {
		$('#msg').html(data.msg);
	}).fail( function( xhr, statur, error ) {
		$('#msg').html( "There is problem. Please try again! + ("+textStatus+")" );
	}); 
};